/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.p10.miage.gestionnote.action;

import fr.p10.miage.gestionabsence.model.Connection;
import fr.p10.miage.gestionabsence.model.Etudiant;
import fr.p10.miage.gestionabsence.model.SessionUtilisateur;
import fr.p10.miage.gestionnote.model.Formations;
import fr.p10.miage.gestionnote.modelservice.ControleServices;
import fr.p10.miage.gestionnote.modelservice.UtilService;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.chain.contexts.ServletActionContext;

/**
 *
 * @author charleshenzel
 */
public class NotesEtudiantAction extends org.apache.struts.action.Action 
{

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        ActionForward forward = mapping.getInputForward();
        
        Etudiant etudiant = (Etudiant) SessionUtilisateur.getUtilisateur(request);
        HttpSession session = request.getSession();           
        //ServletContext ctx = (ServletContext) session.getServletContext(); 
        //Connection db = (Connection) ctx.getAttribute("db");
        //UtilService.setBdd(db);
        //ControleServices.setIdEtudiant(etudiant.getId());
        
        //UtilService.setIdEtudiant(etudiant.getId());
        
        Formations listeFormations = new Formations(etudiant.getId());
        
        
        
        request.setAttribute("listeFormations",listeFormations);
        
        forward = mapping.findForward("notes-etudiant");
        return forward;
    }
}
